import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            String[] s = sc.nextLine().trim().split(" ");
            int[] nums = new int[s.length];
            for (int i = 0; i < s.length; i++) {
                nums[i] = Integer.parseInt(s[i]);
            }
            int target = sc.nextInt();
            System.out.println(findNumCount(nums, target));
            sc.nextLine();
        }
    }

    /*有序一定要想到二分查找*/
    public static int findNumCount(int[] arr, int target) {

        int l = 0, pivot = 0, r = arr.length - 1;

        while (l <= r) {
            pivot = (l + r) / 2;
            if (arr[pivot] == target) {
                int i = pivot, j = pivot;
                while (arr[i] == target) i--;
                while (arr[j] == target) j++;
                return j - i - 1;
            } else if (arr[pivot] > target) {
                r = pivot;
            } else l= pivot;

        }
        return 0;
    }
}
